package com.haliyoo.adhere.widget;


import com.haliyoo.adhere.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * 对话框提示
 */
public class PromptDialog {


	/**
	 * 确定对话框并回调函数
	 * @param context
	 * @param showStr
	 * @param DialogListener
	 * @param flag
	 */
	public static void show(final Context context,final String showStr, final DialogListener dialogListener)
	{
		show(context, showStr, dialogListener,-1);
	}
	
	
	/**
	 * 确定对话框并回调函数
	 * @param context
	 * @param showStr
	 * @param dialogListener
	 * @param flag
	 */
	public static void show(final Context context,final String showStr, final DialogListener dialogListener,final int flag)
	{
		final AlertDialog.Builder dialog = new AlertDialog.Builder(context);
		dialog.setTitle(context.getString(R.string.dialog_title));
		dialog.setMessage(showStr);	
		dialog.setPositiveButton(context.getString(R.string.dialog_comfirm), new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
				if(dialogListener!=null){
					dialogListener.doComfirm(flag);
				}
			}
		});
		dialog.show();
	}
	
	/**
	 * 确定、取消对话框并回调函数
	 * @param context
	 * @param showStr
	 * @param dialogListener
	 * @param flag
	 */
	public static void show(final Context context,final String showStr,final DialogListener dialogListener, final boolean isCancel)
	{
		show(context, showStr, dialogListener, -1, isCancel);
	}
	
	/**
	 * 确定、取消对话框并回调函数
	 * @param context
	 * @param showStr
	 * @param DialogListener
	 * @param flag
	 */
	public  static void show(final Context context,final String showStr, final DialogListener dialogListener, final int flag, final boolean isCancel)
	{
		final AlertDialog.Builder dialog = new AlertDialog.Builder(context);
		dialog.setTitle(context.getString(R.string.dialog_title));
		dialog.setMessage(showStr);	
		dialog.setPositiveButton(context.getString(R.string.dialog_comfirm), new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
				if(dialogListener!=null){
					dialogListener.doComfirm(flag);
				}
			}
		});
		dialog.setNegativeButton(context.getString(R.string.dialog_cancel),new DialogInterface.OnClickListener(){

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
				if(dialogListener!=null){
					if(isCancel){
						dialogListener.doCancel(flag);
					}
				}
			}

		});
		dialog.show();
	}
}
